package org.hsieh.tr.explore.db;

import java.sql.Connection;
import java.sql.SQLException;

import org.hsieh.tr.explore.ui.ISqlResultView;

/**
 * Record all the connection actions
 * 
 * @author xiaowei.ye xiaowei.ye@soyatec.com
 * 
 */
public interface IConnectionWarpper {

    public Connection getConnection();

    public void dispose();

    /**
     * Just send the sql to database and return the result
     * 
     * @param sql
     * @throws SQLException
     */
    public void submit(String sql) throws Exception;

    /**
     * Send sql to database and commit the transaction.
     * 
     * @param sql
     * @throws SQLException
     */
    public void commit(String sql) throws Exception;

    /**
     * Just call {@link Connection} commit operation.
     * 
     * @throws SQLException
     */
    public void pureCommit() throws SQLException;

    public void addResultView(ISqlResultView view);

    public void removeResultView(ISqlResultView view);

    public void rollback() throws SQLException;
}
